<?php
declare (strict_types = 1);

namespace app\validate;

use think\Validate;

class WebsiteValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id|网站ID' => 'require|number',
        'title|网站名称' => 'require|length:2,80',
        'domain|网站域名' => 'require|unique:website|regex:/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?/',
    ];

    protected $scene = [
        'save' => ['title','domain'],
        'update' => ['id','title','domain'],
    ];

    protected $message = [
        'domain.regex' => '域名格式错误',
    ];
}
